#include <stdio.h>
#include <stdlib.h>

typedef int ElemType; 
typedef struct _node{
	ElemType data;
	char *str; 
	struct _node*next; 
}node;
node* makenode(ElemType num,char *p[int i])
{	
	 	
	node* H = (node*)malloc(sizeof(node)); 
	H->data = num;
	H->next =NULL;
	H->str = p[i]; 
	return H;
}

void traversa(node*H)
{
	node* p = H;    
	while (p->next != NULL)
	{
	printf("%d,%s\n",p->data,p->str);
		p = p->next;		
//	printf("%d\n",p->data);
	}
	printf("%d,%s\n",p->data,p->str);
//	printf("%d\n",H->data);
//	printf("%d,%s\n",p->data,H->str);
}

void insert_to_tail(node*H,node*q)
{
	node*p = H; 	
	while (p->next != NULL)
	{
		p = p->next;		
	}        	
		p->next = q;
}

node* insert_to_head(node*H,node*p)
{	 		
	p->next = H;
	return p;	
}

node* insert_middle(node*H,ElemType num,ElemType flag,node*y)
{
	node*p,*q;
	if (num == H->data && 0 ==flag)        
	{
		y->next = H;
		return y;
	}
	if (num == H->data && 0 !=flag)
	{
		y->next = H->next;
		H->next = y;
		return H;
	}	
	
        		
		for(p=H;p->next !=NULL;)     
		{
			q = p;
		       	p = p->next;
			if (num == p->data)
			{
				break;   
			}		
		}   
			if (0 == flag)
			{
			q->next = y;
		       	y->next = p;
			}	
		else
		{
			y->next = p->next;
			p->next = y;
		}
        return H;	
}
node* delete(node*H,ElemType num)
{
	node*p,*q;
	if (num == H->data)
	{
		q = H->next;
		free(H);
		return q;
	}
	else
	{	
	 	for(p=H;p->next != NULL;)
		{
			q = p;
			p = p->next;
		    	if(num == p->data)
			break;	
		}
		 	q->next = p->next;
			free(p);
			return H;	
	}
}
int main(void)
{
	ElemType id;
	int i;
	int s;
	char *p[5];
	node* H =(node*)malloc(sizeof(node));
        printf("name,id\n");
	scanf("%s",p[0]);
	scanf("%d",&id);
        H = makenode(id,p[0]);
	traversa(H);
	for (i=0;i < 4;i++)
	{
        printf("请输入第%d个成员名字和学号\n",i+2);
	scanf("%s",p[i]);
	scanf("%d",&id);
	insert_to_tail(H,makenode(id,p[i]));
	}	
	traversa(H);
	return 0;    
}	
